<?php

namespace app\api\controller;

use think\Controller;
use app\service\User;
use app\service\Table;
use app\service\Union;
use app\common\model\RoomModel;
use app\common\utils\RedisUtils;
use think\facade\Cache;
use app\service\Chess;
use app\chess\Poker;
use app\common\model\UserMsgModel;
use app\handle\Table as hTable;
use app\handle\Game as hGame;
use app\chess\NewPoker;
use app\common\model\TableModel;

Class Test extends Controller
{

    public function tableE()
    {
        dump((new TableModel)->isExistTable(126591));
    }

    public function sstatus()
    {
        $newPoker = new NewPoker();
        $cards = $newPoker->doShuffle();
        dump($cards);
    }
    public function sstatus1()
    {
        $this->sstatus($status=true);
    }
    public function sstatus2()
    {
        $this->sstatus($b=true);
    }


    public function nextEle()
    {
        $c = 0;
        $arr = array(
            0 => 'fa0',
            2 => 'fa2',
            3 => 'fa3',
            4 => 'fa4'
        );

        $next  = 0;
        $count = 0;
        for ($i=$c; $i<5; $i++) {
            if (!empty($arr[$i])) {
                $next = $i;
                $count++;
                if ($count >= 2) break;
            }
        }

        if ($c == $next) {
            $next = key($arr);
        }

        echo $next."<br />";
        echo $arr[$next]."<br />";
    }


    public function td()
    {
        $data = (new Table())->getTableByUnionId(395550);
        dump(json_decode($data['list'], true));
    }
    public function pos()
    {
        $h = new hTable(126592, 196026);
        $g = new hGame(126592, 196026);
        dump($h->playerHasATable());
        dump($h->getCids());

        $ary = $g->getSpeakFlows();
        dump($ary);
        ksort($ary);
        dump($ary);
        dump($g->getSpeakPos());
        dump($g->getNextNotDisCardPos());
    }

    public function clear()
    {
        Cache::clear();
    }

}